

import 'package:xim/widget/dash_chat_2/dash_chat_2.dart';

extension ChatMessageExtension on ChatMessage {

  String get messageId  {
    return customProperties![ChatMessageExtensionFields.messageId.key];
  }

  /// 解密后的密钥
  String get secretKey  {
    return customProperties![ChatMessageExtensionFields.secretKey.key];
  }

  String? get attachment  {
    return customProperties![ChatMessageExtensionFields.attachment.key];
  }

}

enum ChatMessageExtensionFields {
  messageId("messageId", false, String),
  secretKey("secretKey", false, String),
  attachment("attachment",true, String),
  ;

  final String key;
  final bool nullable;
  final Type type;

  const ChatMessageExtensionFields(this.key, this.nullable, this.type);

}